const query = require("../db/mysql")
const { success, error } = require("../module/module")


class Information {
    //获取消息数据
    getMegList = async (ctx) => {
        let sql = 'select * from message where 1=1  '
        let data = await query(sql)
        ctx.body = success(data)


    }
    //消息删除
    deleteMes = async (ctx) => {
        let { id } = ctx.request.body
        let sql = `delete from message where id=${id} `
        let data = await query(sql)

        if (data.affectedRows === 1) {
            ctx.body = success(data, '删除成功')
        } else {
            ctx.body = error("没有此数据，删除失败！")
        }
    }
    //通告
    announcement = async (ctx) => {
        let sql = 'select * from announcement where 1=1  '
        let data = await query(sql)
        ctx.body = success(data)
    }
}


module.exports = new Information()